/**
 *
 * \file DirParser.cpp
 *\brief DirParser declaration class for Linux platforms
 * \author Edouard ROGE
 * \date 27 february 2011
 *
 */

#include <stdlib.h>
#include "DirParser.h"

DirParser::DirParser()
{
	m_Ent = NULL;
	m_Dir = NULL;
}

DirParser::~DirParser()
{
}

bool DirParser::Open( const std::string & _strURI, const std::string & _strExt )
{
	m_URI = _strURI + "*." + _strExt;
	m_Dir = opendir(m_URI.GetURI().c_str());
	return m_Dir != NULL;
}

bool DirParser::Close()
{
	closedir(m_Dir);
	return true;
}

bool DirParser::Iterate( std::string & _strFileName )
{

	if( m_Dir != NULL )
	{
		m_Ent = readdir(m_Dir);
		if( m_Ent != NULL )
		{
			_strFileName = m_Ent->d_name;
			return true;
		}
	}
	return false;
}
